/**
 * 由 WangYu 创建
 * 日期 2017/9/14
 */
import React, {Component} from 'react';
import {
    StyleSheet,
    Text,
    View,
    Image,
    TouchableOpacity, ScrollView,
} from 'react-native';
import HomeComponentTitleView from "./HomeComponentTitleView";
import ShopCenterItemView from "./ShopCenterItemView";
export default class HomeShopCenterView extends Component {

    constructor(props) {
        super(props);
    }

    render() {
        let data = this.props.data;
        return (
            <View style={styles.container}>
                <HomeComponentTitleView leftIcon={'gw'}
                                        leftTitle={'购物中心'}
                                        rightTitle={data.tips}/>
                <ScrollView horizontal={true} showsHorizontalScrollIndicator={false} style={{flex: 1}}>
                    {this.renderItemView()}
                </ScrollView>
            </View>
        );
    }

    renderItemView() {
        let itemArr = [];
        let dataArr = this.props.data.data;
        for (let i = 0; i < dataArr.length; i++) {
            itemArr.push(
                <ShopCenterItemView
                    image={dataArr[i].img}
                    dec={dataArr[i].showtext.text}
                    text={dataArr[i].name}
                    url={dataArr[i].detailurl}
                    key={i}
                    navigation={this.props.navigation}/>
            );
        }
        return itemArr;
    }
}

const styles = StyleSheet.create({
    container: {
        height: 180,
        backgroundColor: 'white'
    },
});
